package com.lishe.lishe.lishe.bean;

import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created by lwa on 2017/8/12.
 * 商品对象
 */

public class GoodObject extends BusinessObject implements Serializable {

    /**
     * 商品id
     */
    private String goodsId;
    /**
     * 商品名称
     */
    private String goodsName;
    /**
     * 商品订单id
     */
    private String goodsPaymentId;
    /**
     * 商品描述
     */
    private String goodsDescribe;
    /**
     * 商品规格
     */
    private String goodsFormat;
    /**
     * 商品单价
     */
    private double goodsPrice;
    /**
     * 商品总价
     */
    private double goodsTotalPrice;

    /**
     * 商品数量
     */
    private int goodsCount;
    /**
     * 商品重量
     */
    private String goodsWeight;

    /**
     * 商品信息
     */
    private String goodsInfo;
    /**
     * 商品颜色
     */
    private String goodsColor;
    /**
     * 商品图片链接
     */
    private String goodsImgUrl;
    /**
     * 商品备注
     */
    private String goodsNote;
    /**
     * 商品所在动物车的id
     */
    private String cartId;

    /**
     * 商品库存id
     */
    private String skuId;

    /**
     * 商品所商店id
     */
    private String shopId;
    /**
     * 打折前的价格
     */
    private double mkt_price;
    /**
     * 选中标志
     */
    private boolean isCheck = false;
    private String itemId;


    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsDescribe() {
        return goodsDescribe;
    }

    public void setGoodsDescribe(String goodsDescribe) {
        this.goodsDescribe = goodsDescribe;
    }

    public String getGoodsFormat() {
        return goodsFormat;
    }

    public void setGoodsFormat(String goodsFormat) {
        this.goodsFormat = goodsFormat;
    }


    public int getGoodsCount() {
        return goodsCount;
    }

    public void setGoodsCount(int goodsCount) {
        this.goodsCount = goodsCount;
    }

    public String getGoodsWeight() {
        return goodsWeight;
    }

    public void setGoodsWeight(String goodsWeight) {
        this.goodsWeight = goodsWeight;
    }

    public String getGoodsInfo() {
        return goodsInfo;
    }

    public void setGoodsInfo(String goodsInfo) {
        this.goodsInfo = goodsInfo;
    }

    public String getGoodsColor() {
        return goodsColor;
    }

    public void setGoodsColor(String goodsColor) {
        this.goodsColor = goodsColor;
    }

    public String getGoodsImgUrl() {
        return goodsImgUrl;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsPaymentId() {
        return goodsPaymentId;
    }

    public void setGoodsPaymentId(String goodsPaymentId) {
        this.goodsPaymentId = goodsPaymentId;
    }

    public double getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(double goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public void setGoodsImgUrl(String goodsImgUrl) {
        this.goodsImgUrl = goodsImgUrl;
    }

    public String getGoodsNote() {
        return goodsNote;
    }

    public void setGoodsNote(String goodsNote) {
        this.goodsNote = goodsNote;
    }

    public String getCartId() {
        return cartId;
    }

    public void setCartId(String cartId) {
        this.cartId = cartId;
    }

    public String getSkuId() {
        return skuId;
    }

    public void setSkuId(String skuId) {
        this.skuId = skuId;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public double getGoodsTotalPrice() {
        this.goodsTotalPrice = goodsPrice * goodsCount;
        return goodsTotalPrice;
    }

    public double getMkt_price() {
        return mkt_price;
    }

    public void setMkt_price(double mkt_price) {
        this.mkt_price = mkt_price;
    }

    @Override
    public boolean isCheck() {
        return isCheck;
    }

    @Override
    public void setCheck(boolean check) {
        isCheck = check;
    }

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public void optJson(GoodObject goodObject, JSONObject jsonObject) {
        goodObject.setGoodsDescribe(jsonObject.optString("title"));
        goodObject.setGoodsWeight(jsonObject.optString("total_weight"));
        goodObject.setGoodsCount(jsonObject.optInt("num"));
        goodObject.setGoodsPrice(jsonObject.optDouble("price"));
        goodObject.setGoodsImgUrl(jsonObject.optString("pic_path"));
        goodObject.setItemId(jsonObject.optString("item_id"));
        if (jsonObject.optString("spec_info").equals("") || jsonObject.optString("spec_info").equals("null")) {
            goodObject.setGoodsFormat("默认规格");
        } else {
            goodObject.setGoodsFormat(jsonObject.optString("spec_info"));
        }

    }
}
